#ifndef GAMEBOARD_H
#define GAMEBOARD_H

#include <QWidget>
#include "tile.h"

class GameBoard : public QWidget {
    Q_OBJECT
public:
    explicit GameBoard(QWidget *parent = nullptr);
    void slide(Qt::ArrowType moveDirection);//滑动
    int get_tiles_value(int i ,int j);

    int set_tile_value_0_num(int num);
    int get_tile_value_0_num();
protected:
    void mouseMoveEvent(QMouseEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;

private:
    Tile *tiles[4][4];
    int tile_row=4;
    int tile_col=4;
    int tile_value_0_num=0;

    QPoint pressPos;      // 用于存储鼠标按下时的位置
    QPoint lastPos;       // 用于存储鼠标最后的位置（在mouseMoveEvent中更新）
    Qt::ArrowType moveDirection; // 用于存储移动的方向（如Qt::LeftArrow, Qt::RightArrow等）
    bool isMousePressed;  // 标记鼠标是否已被按下
#if 0
    QPoint lastMousePos;
#endif
};

#endif // GAMEBOARD_H
